using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using mvLibrary.Helpers.Utils;
namespace fenk.Varios
{
    public partial class CancelarValeS : mvLibrary.BaseForm
    {
        public CancelarValeS()
        {
            InitializeComponent();
        }
        public override void AfterReadItem()
        {
            
            // SOLO PARA VALES TIPO "2" O "3" (CHEQUES, $FENK)
            if (UniItem.ExtractAsString(12) == "1")
            {
                MessageBox.Show("El tipo de vale debe ser CHEQUE O $FENK",this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                CancelItem();
            }
        }
        public override void BeforeSaveItem()
        {
            // que el total de cancelacion no supere al total del vale
            long totalVale = long.Parse(GetDefaultValue("D4",false,1,1));
            long totalCanc = long.Parse(GetDefaultValue("@CALC T17", false, 1, 1));
            if (totalCanc > totalVale)
            {
                CancelSaveItem = true;
                ErrorMessage = "Total cancelaciones supera total del vale";
            }
            else
            {
                CancelSaveItem = false;
            }
        }
        
    }
}

